package controllers;

import java.util.GregorianCalendar;

import entities.IGarage;
import entities.IMaster;
import entities.IOrder;
import entities.OrderStatus;
import model.workersWithData.DBManager;
import model.workersWithData.sort.SortBy;
import model.workersWithData.sort.SortObjectBy;

public class Autoservice implements IAutoservice {

	private static DBManager dbm = new DBManager();

	public void getEmptyGarage() {
		dbm.getEmptyGarage();
	}

	public void SortOrderByBeginningDate() {
		dbm.SortOrder(SortBy.SortBy(SortObjectBy.SORT_ORDERS_BY_BEGINING_DATE));
	}

	public void SortOrderByDeadlineDate() {
		dbm.SortOrder(SortBy.SortBy(SortObjectBy.SORT_ORDERS_BY_DEADLINE_DATE));
	}

	public void SortOrderByFillingDate() {
		dbm.SortOrder(SortBy.SortBy(SortObjectBy.SORT_ORDERS_BY_FILLING_DATE));
	}

	public void SortOrderByPrice() {
		dbm.SortOrder(SortBy.SortBy(SortObjectBy.SORT_ORDERS_BY_PRICE));
	}

	public void SortMasterByEmployment() {
		dbm.SortMaster(SortBy.SortBy(SortObjectBy.SORT_MASTER_BY_EMPLOYMENT));
	}

	public void SortMasterByName() {
		dbm.SortMaster(SortBy.SortBy(SortObjectBy.SORT_MASTER_BY_NAME));
	}

	public void SortMadingOrderByBeginningDate() {
		dbm.SortMadingOrder(SortBy
				.SortBy(SortObjectBy.SORT_ORDERS_BY_BEGINING_DATE));

	}

	public void SortMadingOrderByDeadlineDate() {
		dbm.SortMadingOrder(SortBy
				.SortBy(SortObjectBy.SORT_ORDERS_BY_DEADLINE_DATE));
	}

	public void SortMadingOrderByFillinggDate() {
		dbm.SortMadingOrder(SortBy
				.SortBy(SortObjectBy.SORT_ORDERS_BY_FILLING_DATE));

	}

	public void SortMadingOrderByPrice() {
		dbm.SortMadingOrder(SortBy.SortBy(SortObjectBy.SORT_ORDERS_BY_PRICE));

	}

	public void getOrderByMaster(String masterName) {
		dbm.getOrdersByMaster(masterName);
	}

	public void getMasterByOrder(Integer numberOrder) {
		dbm.getMastersByOrder(numberOrder);
	}

	public void SortDeletedOrderByPeriodByBeginningDate(
			GregorianCalendar begin, GregorianCalendar end) {
		dbm.SortOrderByPeriod(OrderStatus.DELETED,
				SortBy.SortBy(SortObjectBy.SORT_ORDERS_BY_BEGINING_DATE),
				begin, end);
	}

	public void SortCanceledOrderByPeriodByBeginningDate(
			GregorianCalendar begin, GregorianCalendar end) {
		dbm.SortOrderByPeriod(OrderStatus.CANCELED,
				SortBy.SortBy(SortObjectBy.SORT_ORDERS_BY_BEGINING_DATE),
				begin, end);
	}

	public void SortMadeOrderByPeriodByBeginningDate(GregorianCalendar begin,
			GregorianCalendar end) {
		dbm.SortOrderByPeriod(OrderStatus.MADE,
				SortBy.SortBy(SortObjectBy.SORT_ORDERS_BY_BEGINING_DATE),
				begin, end);
	}

	public void SortDeletedOrderByPeriodByDeadlineDate(GregorianCalendar begin,
			GregorianCalendar end) {
		dbm.SortOrderByPeriod(OrderStatus.DELETED,
				SortBy.SortBy(SortObjectBy.SORT_ORDERS_BY_DEADLINE_DATE),
				begin, end);
	}

	public void SortCanceledOrderByPeriodByDeadlineDate(
			GregorianCalendar begin, GregorianCalendar end) {
		dbm.SortOrderByPeriod(OrderStatus.CANCELED,
				SortBy.SortBy(SortObjectBy.SORT_ORDERS_BY_DEADLINE_DATE),
				begin, end);
	}

	public void SortMadeOrderByPeriodByDeadlineDate(GregorianCalendar begin,
			GregorianCalendar end) {
		dbm.SortOrderByPeriod(OrderStatus.MADE,
				SortBy.SortBy(SortObjectBy.SORT_ORDERS_BY_DEADLINE_DATE),
				begin, end);
	}

	public void SortDeletedOrderByPeriodByFillingDate(GregorianCalendar begin,
			GregorianCalendar end) {
		dbm.SortOrderByPeriod(OrderStatus.DELETED,
				SortBy.SortBy(SortObjectBy.SORT_ORDERS_BY_FILLING_DATE), begin,
				end);
	}

	public void SortCanceledOrderByPeriodByFillingDate(GregorianCalendar begin,
			GregorianCalendar end) {
		dbm.SortOrderByPeriod(OrderStatus.CANCELED,
				SortBy.SortBy(SortObjectBy.SORT_ORDERS_BY_FILLING_DATE), begin,
				end);
	}

	public void SortMadeOrderByPeriodByFillingDate(GregorianCalendar begin,
			GregorianCalendar end) {
		dbm.SortOrderByPeriod(OrderStatus.MADE,
				SortBy.SortBy(SortObjectBy.SORT_ORDERS_BY_FILLING_DATE), begin,
				end);
	}

	public void SortDeletedOrderByPeriodByPrice(GregorianCalendar begin,
			GregorianCalendar end) {
		dbm.SortOrderByPeriod(OrderStatus.DELETED,
				SortBy.SortBy(SortObjectBy.SORT_ORDERS_BY_PRICE), begin, end);
	}

	public void SortCanceledOrderByPeriodByPrice(GregorianCalendar begin,
			GregorianCalendar end) {
		dbm.SortOrderByPeriod(OrderStatus.CANCELED,
				SortBy.SortBy(SortObjectBy.SORT_ORDERS_BY_PRICE), begin, end);
	}

	public void SortMadeOrderByPeriodByPrice(GregorianCalendar begin,
			GregorianCalendar end) {
		dbm.SortOrderByPeriod(OrderStatus.MADE,
				SortBy.SortBy(SortObjectBy.SORT_ORDERS_BY_PRICE), begin, end);
	}

	public void getFreePlacesOnDate(GregorianCalendar date) {
		dbm.getNumberEmptyPlaces(date);
	}

	public void getNextFreeDate() {
		dbm.getNextFreeDate();
	}

	public void addMaster(IMaster master) {
		dbm.addMaster(master);
	}

	public void deleteMaster(String masterName) {
		dbm.deleteMaster(masterName);
	}

	public void addGarage(IGarage garage) {
		dbm.addGarage(garage);
	}

	public void deleteGarage(Integer numberGarage) {
		dbm.deleteGarage(numberGarage);
	}

	public void addOrder(IOrder order, String masterName, Integer numberGarage) {
		dbm.addOrder(order, masterName, numberGarage);
	}

	public void markOrderDeleted(Integer numberOrder) {
		dbm.markOrder(OrderStatus.DELETED, numberOrder);
	}

	public void markOrderCanceled(Integer numberOrder) {
		dbm.markOrder(OrderStatus.CANCELED, numberOrder);
	}

	public void markOrderMade(Integer numberOrder) {
		dbm.markOrder(OrderStatus.MADE, numberOrder);
	}

	public void ShirtTimeOrder(GregorianCalendar newDate, Integer numberOrder) {
		dbm.ShirtTimeOrder(newDate, numberOrder);
	}

	public void resaveData() {
		dbm.saveData();
	}

}
